<!DOCTYPE HTML>
<html>
<head>
    <title>添加商品父分类</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/stylesheets/formdata.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<div class="container">
    <div class="mini-fit" style="height: 320px;">
        <ul id="tree1" class="mini-tree" url="/getdata/selectGoodsTypeForShopIntergation" style="width:100%;height:100%;"
            showTreeIcon="true" textField="text" idField="id" parentField="pid" resultAsTree="false"
            expandOnLoad="true" onnodedblclick="onNodeDblClick" expandOnDblClick="false"
        >
        </ul>
    </div>
    <div class="mini-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;"
         borderStyle="border-left:0;border-bottom:0;border-right:0;">
        <a class="mini-button" style="width:60px;" onclick="onOk()">确定</a>
        <span style="display:inline-block;width:25px;"></span>
        <a class="mini-button" style="width:60px;" onclick="onCancel()">取消</a>
    </div>
</div>
</body>
<script>
  mini.parse();

  var tree = mini.get("tree1");

  tree.on("nodeselect", function (e) {
    // console.log(e)
    if (e.isLeaf) {
    } else {
      alert("请选择一个商品分类子类！");
      // grid.setData([]);
      // grid.setTotalCount(0);
    }
  });

  function GetData() {
    var node = tree.getSelectedNode();
    return node;
  }

  function onNodeDblClick(e) {
    onOk();
  }
  //////////////////////////////////
  function CloseWindow(action) {
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
  }

  function onOk() {
    var node = tree.getSelectedNode();
    if (node && tree.isLeaf(node) == false) {
      alert("请选择一个商品分类子类！");
      return;
    }

    CloseWindow("ok");
  }
  function onCancel() {
    CloseWindow("cancel");
  }

</script>
</html>